{include file="public/layout" /}
{eq name="$editor.editor_select" value="1"}
    {load href="__PUBLIC__/plugins/Ueditor/ueditor.config.js" /}
    {load href="__PUBLIC__/plugins/Ueditor/ueditor.all.min.js" /}
    {load href="__PUBLIC__/plugins/Ueditor/lang/zh-cn/zh-cn.js" /}
{else/}
    {load href="__PUBLIC__/plugins/ckeditor/ckeditor.js" /}
{/eq}
<style type="text/css">
    .layui-layer-setwin {
        position: absolute;
        right: 20px;
        top: 34px;
    }
    .layui-layer-tips {
        margin-top: 0;
    }
    .layui-tree-iconClick {
        line-height: 13px;
    }
    .layui-tree-iconClick .layui-tree-iconArrow {
        display: inline-block;
        padding: 0;
        width: 6px;
        height: 6px;
        border-top: 1px solid #444;
        border-left: 1px solid #444;
        transform: rotate(135deg);
    }
    .layui-tree-spread>.layui-tree-entry .layui-tree-iconClick>.layui-tree-iconArrow {
        transform: rotate(225deg);
    }
   .layui-tree-iconClick .layui-tree-iconArrow:after {
       display: none;
   }
</style>
<body style="overflow: auto; cursor: default; -moz-user-select: inherit;background-color:#F4F4F4; ">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="shop_product/left" /}
<div id="geduan_div" class="h10"></div>
<div class="page shop-page shop-ncap-form-default" style="min-width:auto;margin-left:110px;">
    <div class="flexigrid">
        <div class="fixed-bar">
            <div class="item-title">
                <a class="back_xin" href="javascript:history.back();" title="返回"><i class="iconfont e-fanhui"></i></a>
                <div class="subject"> <h3>发布商品</h3> <h5></h5> </div>
                <ul class="tab-base nc-row">
                    <li><a href="javascript:void(0);" data-index='1' class="tab current"><span>基础设置</span></a></li>
                    <li><a href="javascript:void(0);" data-index='2' class="tab "><span>商品详情</span></a></li>
                    <li><a href="javascript:void(0);" data-index='3' class="tab "><span>商品参数</span></a></li>
                    <!-- {empty name="$global['web_status']"}
                    <li><a href="javascript:void(0);" data-index='4' class="tab"><span>更多设置</span></a></li>
                    {/empty} -->
                </ul>
            </div>
        </div>

        <form class="form-horizontal pl10 pr10" id="post_form" action="{:url('ShopProduct/add', ['source'=>'save'])}" method="post">
            <!-- 基础设置 -->
            <div class="ncap-form-default tab_div_1">
                <div class="div_title"> 基础信息 </div>
                <dl class="row">
                    <dt class="tit"> <label for="title"><em>*</em>商品名称</label> </dt>
                    <dd class="opt">
                        <input type="text" name="title" id="title" class="input-txt" maxlength="200" {eq name="$channelRow.is_repeat_title" value="0"} oninput="check_title_repeat(this, 0);" {/eq}>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label for="subtitle">商品副标题</label> </dt>
                    <dd class="opt">
                        <input type="text" name="subtitle" id="subtitle" class="input-txt" maxlength="200">
                    </dd>
                </dl>

                <dl class="row">
                    <dt class="tit"> <label for="marketing_label">商品标签</label> </dt>
                    <dd class="opt">
                        <div class="inpit-word">
                            <input type="text" name="marketing_label" id="marketing_label" placeholder="请输入商品标签" autocomplete="off" oninput="inputLengthShow(this, 'marketing_label');" maxlength="4" onpropertychange="if(value.length>4) value=value.substr(0,4)">
                            <div class="word"><span class="marketing_label_text_count">0</span>/<span class="num_count">4</span></div>
                        </div>
                        <p class="notic">显示在商品列表和商品详情标题上的标签，不可超过四个字</p>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label><em>*</em>商品主图</label> </dt>
                    <dd class="opt">
                        <div class="dan-pane">
                            <div class="images_upload images_upload_html" style="display: inline-block;">
                                <a href="javascript:void(0);" onclick="GetUploadify(1, '', 'allimg', 'goodsPicCallBack');" class="img-upload mb15" title="点击上传">
                                    <div class="y-line" id="litpic_y_line"></div>
                                    <div class="x-line" id="litpic_x_line"></div>
                                    <img src="" id="litpic_src" class="pic_con" style="display: none;">
                                </a>
                                <a href="javascript:void(0)" onclick="goodsPicClear();" class="delect" id="litpic_delect" style="display: none;"></a>
                                <input type="hidden" id="litpic" name="litpic" value="">
                            </div>
                            <script type="text/javascript">
                                function goodsPicCallBack(fileurl_tmp) {
                                    $('#litpic').val(fileurl_tmp);
                                    $("input[name=is_litpic]").attr('checked', true);
                                    $('#litpic_src').show().attr('src', fileurl_tmp);
                                    $('#litpic_y_line, #litpic_x_line').hide();
                                    if (fileurl_tmp) $('#litpic_delect').attr('style', '');

                                    // 同步加载或更新商品轮播图相关图片
                                    goodsSynchImages($('#goods_synch_images'));
                                }

                                function goodsPicClear() {
                                    $('#litpic').val('');
                                    $('#litpic_src').hide().attr('src', '');
                                    $("input[name=is_litpic]").attr('checked', false);
                                    $('#litpic_y_line, #litpic_x_line').show();
                                    $('#litpic_delect').attr('style', 'display: none;');

                                    // 同步删除商品轮播图相关图片
                                    goodsSynchImages($('#goods_synch_images'));
                                }
                            </script>
                        </div>
                        <span class="err"></span>
                        <div style="clear: both;"></div>
                        <label>
                            <input type="checkbox" name="goods_synch_images" id="goods_synch_images" value="1" onclick="goodsSynchImages(this);"> 显示为商品轮播图
                        </label>
                        <script type="text/javascript">
                            function goodsSynchImages(obj) {
                                if (true == $(obj).is(':checked')) {
                                    var litpic_url = $('#litpic').val() ? $('#litpic').val() : '/public/static/common/images/default_litpic_x.png';
                                    // 同步加载或更新商品轮播图相关图片
                                    proimg_call_back([litpic_url], true);
                                } else {
                                    // 同步删除商品轮播图相关图片
                                    $('#litpicSync').remove();
                                }
                            }
                            $(document).ready(function() {
                                $('#goods_synch_images').click();
                            });
                        </script>
                        <!-- <p class="notic2">默认显示为商品轮播图</p> -->
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label for="video_paths">主图视频</label> </dt>
                    <dd class="opt">
                        <video style='width: 260px; height: 145px;' id='video' controls preload='auto' oncontextmenu='return fase'></video>
                        <div>
                            <input type="hidden" name="video_times" id="video_times">
                            <input type="text" name="video_paths" id="video_paths" class="input-txt" placeholder="在此输入外链视频地址" onchange="videoPaths(this);">
                            <input type="file" id="clickUpload" onchange="videoUpload(this);" style="display: none;">
                            <a href="javascript:void(0);" class="ncap-btn ncap-btn-green" id="videoUpload" onclick="$('#clickUpload').trigger('click');">点击上传</a>
                            <a href="javascript:void(0);" class="ncap-btn ncap-btn-green" onclick="videoClear();">清除</a>
                        </div>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label>商品轮播图</label> </dt>
                    <dd class="opt">
                        <div class="tab-pane pics" id="tab_proimg">
                            <table class="table table-bordered">
                                <tbody>
                                    <tr>
                                        <td>
                                            <div class="sort-list-img"> <div class="images_upload"></div> </div>
                                            <a href="javascript:void(0);" onClick="GetUploadify(30,'','allimg','proimg_call_back');" class="img-upload mb15" title="点击上传"> <div class="y-line"></div> <div class="x-line"></div> </a>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        <!-- 上传图片显示的样板 start -->
                        <div class="images_upload_tpl none">
                            <div class="images_upload images_upload_html">
                                <div class="images_upload_box">
                                    <input type="hidden" name="proimg[]" />
                                    <a href="javascript:void(0);" onclick="Images('{$vo[\'image_url\']}',900,600)" class="upimg" title="拖动修改排序">
                                        <img src="__STATIC__/admin/images/add-button.jpg"/>
                                    </a>
                                    <a href="javascript:void(0)" class="delect" title="删除">&nbsp;&nbsp;</a>
                                </div>
                            </div>
                        </div>
                        <!-- 上传图片显示的样板 end -->
                        <span class="err"></span>
                        <p class="notic2">建议尺寸: 800*800像素, 轮播图可以拖拽图片调整顺序,最多上传10张</p>
                    </dd>
                </dl>

                <dl class="row" style="z-index: 2;">
                    <dt class="tit">
                        <label for="title">商品分类</label>
                    </dt>
                    <dd class="opt wrapper">
                        <div id="type_tree_data" class="select-tree-wrap">
                            <div class="input-keyword-wrap">
                                <div class="select-menu-input imitationSelect role_select" onclick="show_type();">
                                    <p class="input-tips">请选择</p>
                                </div>
                                <!-- 收缩时 -->
                                <i class="fa handle-arrow fa-caret-up" style="display: none; cursor: pointer;"></i>
                                <!-- 点开时 -->
                                <i class="fa handle-arrow fa-caret-down" style="cursor: pointer;"></i>
                            </div>
                        </div>
                        <div id="type_tree" class="select-tree-down" style="display: none;"></div>
                        <span class="err"></span>
                    	<p class="notic"></p>
                    </dd>
                </dl>
                <script type="text/javascript" src="__PUBLIC__/plugins/layui-v2.9.10/layui.js?v={$version}"></script>
                <script>
                    function show_type() {
                        var type_tree_display = $('#type_tree').css('display');  
                        if ('none' == type_tree_display) {
                            $('#type_tree').show();
                            $('.fa-caret-up').show();
                            $('.fa-caret-down').hide();
                        } else {
                            $('#type_tree').hide();
                            $('.fa-caret-up').hide();
                            $('.fa-caret-down').show();
                        }
                    }

                    $(document).on('click', function(e) {
                        if ($(e.target).closest('.fa-caret-down').length) {
                            $('#type_tree').show();
                            $('.fa-caret-up').show();
                            $('.fa-caret-down').hide();
                        }
                        else if ($(e.target).closest('.layui-tree-txt').length) {
                            $(e.target).parent().find('.layui-form-checkbox').click();
                        }
                        else if (!$(e.target).closest('.select-menu-input, .select-tree-down, .close').length) {
                            $('#type_tree').hide();
                            $('.fa-caret-up').hide();
                            $('.fa-caret-down').show();
                        }
                    });

                    var SampleJSONData = {$arctypeList};
                    SampleJSONData = JSON.stringify(SampleJSONData);
                    SampleJSONData = JSON.parse(SampleJSONData);
                    layui.use(function(){
                        var tree = layui.tree,util = layui.util;
                        // 模拟数据
                        var data = SampleJSONData;
                            // 渲染
                        tree.render({
                            elem: '#type_tree',
                            id: 'type_tree_id',
                            data: data,
                            showCheckbox: true,  // 是否显示复选框
                            onlyIconControl: true,  // 是否仅允许节点左侧图标控制展开收缩
                            showLine: false,  // 是否开启连接线
                            oncheck: function(obj){
                                var checkData = tree.getChecked('type_tree_id');
                                var html = "";
                                checkData.forEach(function( value, index ) {
                                    var name = value.title;
                                    if (value.children){
                                        value.children.forEach(function( val, i ) {
                                            var s_name = name + "->"+ val.title;
                                            if (val.children){
                                                val.children.forEach(function( v, i ) {
                                                    var t_name = s_name + "->"+ v.title;
                                                    html += '<span class="input-keyword-item">\n' +
                                                        '       <span>'+t_name+'</span>\n' +
                                                        '       <i class="iconfont e-quxiao close" lay-on="setChecked"></i>\n' +
                                                        '       <input type="hidden" name="stypeid[]" value="'+ v.id+'">\n' +
                                                        '    </span>';
                                                })
                                            }else {
                                                html += '<span class="input-keyword-item">\n' +
                                                    '       <span>'+s_name+'</span>\n' +
                                                    '       <i class="iconfont e-quxiao close" lay-on="setChecked"></i>\n' +
                                                    '       <input type="hidden" name="stypeid[]" value="'+ val.id+'">\n' +
                                                    '    </span>';
                                            }
                                        })
                                    }else {
                                        html += '<span class="input-keyword-item">\n' +
                                            '       <span>'+name+'</span>\n' +
                                            '       <i class="iconfont e-quxiao close" lay-on="setChecked"></i>\n' +
                                            '       <input type="hidden" name="stypeid[]" value="'+ value.id+'">\n' +
                                            '    </span>';
                                    }
                                });

                                if (html == '') html = '<p class="input-tips">请选择</p>';
                                $(".role_select").html(html);
                            }
                        });

                        // 按钮事件
                        util.event('lay-on', {
                            setChecked: function(obj){
                                var checked_arr = [];
                                $(obj).parent().remove();
                                tree.reload('type_tree_id', { // options
                                    data: data
                                });

                                $(".role_select input").each(function(){
                                    checked_arr.push(parseInt($(this).val()));
                                });
                                tree.setChecked('type_tree_id', checked_arr); // 勾选对应 id 值的节点
                                if (0 === parseInt(checked_arr.length)) $(".role_select").html('<p class="input-tips">请选择</p>');

                                // 再次执行显示隐藏判断
                                show_type();
                            }
                        });
                    });
                </script>
                <dl class="row">
                    <dt class="tit"> <label>商品服务</label> </dt>
                    <dd class="opt">
                        <span id="goodsLabelList">
                            {volist name='$goodsLabel' id='vo'}
                            <label><input type="checkbox" name="goodsLabelID[]" value="{$vo.label_id}" {notempty name="$vo.selected"}checked="checked"{/notempty}>{$vo.label_title}</label>&nbsp;
                            {/volist}
                        </span>
                    </dd>
                </dl>

                <div class="div_title"> 价格库存 </div>
                {if condition="!empty($shopConfig['shop_open_spec'])"}
                <dl class="row">
                    <dt class="tit"> <label>商品规格</label> </dt>
                    <dd class="opt">
                        <label><input type="radio" id="spec_type1" name="spec_type" value="1" checked="true" onclick="selectSpecType(1);">单规格</label>
                        &nbsp;
                        <label><input type="radio" id="spec_type2" name="spec_type" value="2" onclick="selectSpecType(2);">多规格</label>
                    </dd>
                </dl>
                <dl class="row spec_type_2" style="display: none;">
                    <dt class="tit"> </dt>
                    <dd class="opt">
                        <div>
                            <div id='SpecSelectName'></div>
                            <input type="hidden" id="spec_mark_id_arr">
                            <input type="hidden" id="maxPresetMarkID" value="{$maxPresetMarkID}">
                            <div id="addSpecButton">
                                <a href="JavaScript:void(0);" id="addCustomSpec" data-value="0" onclick="addCustomSpec(this);" class="ml15">+新增规格</a>
                                &nbsp; &nbsp; &nbsp;
                                <!-- <select class="preset-select" name="spec_value" id="spec_value" onchange="addPresetSpec(this)">
                                    <option value="0">从规格库提取</option>
                                    {volist name="preset_value" id="vo"}
                                    <option value="{$vo.preset_mark_id}">{$vo.preset_name}</option>
                                    {/volist}
                                </select> -->
                            </div>
                        </div>
                    </dd>
                </dl>
                <dl class="row spec_type_2" style="display: none;">
                    <dt class="tit"> <label>价格/库存</label> </dt>
                    <dd class="opt"> <div id='SpecTempLateDiv'></div> </dd>
                </dl>
                <!-- 产品规格JS -->
                <script type="text/javascript">
                    var aid = 0;
                    var action = 'add';
                    var goodsSpecImage = "{:url('ShopProduct/goodsSpecImage', ['_ajax'=>1])}";
                    // 初始化规格，清除多余规格数据
                    var initializationSpec = "{:url('ShopProduct/initialization_spec', ['_ajax'=>1])}";
                    // 商品规格检测是否有空值
                    var goodsSpecDetectionUrl = "{:url('ShopProduct/goods_spec_detection', ['_ajax'=>1])}";
                    // 保存编辑商品价格库存
                    var editProductSpecPrice = "{:url('ShopProduct/edit_product_spec_price', ['_ajax'=>1])}";
                    // 添加产品自定义规格
                    var addProductCustomSpec = "{:url('ShopProduct/add_product_custom_spec', ['_ajax'=>1])}";
                    // 删除产品自定义规格
                    var delProductCustomSpec = "{:url('ShopProduct/del_product_custom_spec', ['_ajax'=>1])}";
                    // 添加产品自定义规格名
                    var addProductCustomSpecName = "{:url('ShopProduct/add_product_custom_spec_name', ['_ajax'=>1])}";
                    // 添加产品自定义规格值
                    var addProductCustomSpecValue = "{:url('ShopProduct/add_product_custom_spec_value', ['_ajax'=>1])}";
                </script>
                <script type="text/javascript" src="__SKIN__/js/admin_shop_product.js?v={$version}"></script>
                {else/}
                <input type="hidden" name="spec_type" value="1">
                {/if}
                <div class="spec_type_1">
                    <dl class="row">
                        <dt class="tit"> <label for="users_price"><em>*</em>销售价</label> </dt>
                        <dd class="opt">
                            <input type="text" name="users_price" id="users_price" onpaste='this.value=this.value.replace(/^\D*([0-9]\d*\.?\d{0,2})?.*$/, "$1");' onkeyup='this.value=this.value.replace(/^\D*([0-9]\d*\.?\d{0,2})?.*$/, "$1");'>&nbsp;元
                        </dd>
                    </dl>
                    <dl class="row">
                        <dt class="tit"> <label for="crossed_price">划线价</label> </dt>
                        <dd class="opt">
                            <input type="text" name="crossed_price" id="crossed_price" onpaste='this.value=this.value.replace(/^\D*([0-9]\d*\.?\d{0,2})?.*$/, "$1");' onkeyup='this.value=this.value.replace(/^\D*([0-9]\d*\.?\d{0,2})?.*$/, "$1");'>&nbsp;元
                        </dd>
                    </dl>
                    <!-- 会员折扣价 -->
                    <dl class="row">
                        <dt class="tit"> <label>会员折扣价</label> </dt>
                        <dd class="opt">
                            <label><input type="radio" name="users_discount_type" value="0" onclick="selectDiscountType(0)" checked="true"/>系统默认</label>&nbsp;
                            <label><input type="radio" name="users_discount_type" value="1" onclick="selectDiscountType(1)"/>指定会员级别</label>&nbsp;
                            <label><input type="radio" name="users_discount_type" value="2" onclick="selectDiscountType(2)"/>不参与</label>
                            <p class="notic">选择系统默认时，商品价格将会根据会员中心>会员级别里设置的折扣而变化</p>
                            <!-- 会员折扣模板框架 -->
                            <div id="usersDiscountPrice" style="display: none; padding-top: 10px;"></div>
                        </dd>
                    </dl>
                    <script type="text/javascript">
                        var usersDiscountAid = 0;
                        var usersDiscountType = 0;
                        // 选择会员折扣方式
                        function selectDiscountType(value) {
                            if (1 === parseInt(value)) {
                                if (parseInt(usersDiscountType) !== parseInt(value)) {
                                    getUsersDiscountPriceTpl();
                                }
                            } else {
                                usersDiscountType = value;
                                $('#usersDiscountPrice').hide();
                            }
                        }
                        // 获取会员折扣价格模板
                        function getUsersDiscountPriceTpl() {
                            var users_price = $('#users_price').val() ? $('#users_price').val() : 0;
                            $.ajax({
                                type: 'post',
                                url : "{:url('ShopProduct/get_users_discount_price_tpl', ['_ajax'=>1])}",
                                data: {aid: usersDiscountAid, users_price: users_price},
                                dataType: 'json',
                                success: function(res) {
                                    if (1 === parseInt(res.code)) {
                                        usersDiscountType = 1;
                                        $('#usersDiscountPrice').show().html(res.data);
                                    } else {
                                        showErrorAlert(res.msg);
                                    }
                                },
                                error: function(e) {
                                    showErrorAlert(e.responseText);
                                }
                            });
                        }
                        // 批量设置价格
                        function bulkSetUsersDiscountPrice() {
                            layer.prompt({
                                title: false,
                                shade: layer_shade,
                                formType: 3,
                                id: 'usersDiscountPriceID',
                                btn: ['确定', '关闭'],
                                closeBtn: 0,
                                success: function(layero, index){
                                    $("#usersDiscountPriceID").find('input').attr('placeholder', '批量设置价格');
                                    $("#usersDiscountPriceID").find('input').attr('onkeyup', "this.value=this.value.replace(/[^\\d.]/g,'')");
                                    $("#usersDiscountPriceID").find('input').attr('onpaste', "this.value=this.value.replace(/[^\\d.]/g,'')");
                                }
                            }, function(price, index){
                                layer.close(index);
                                $('.users_discount_price').val(price);
                            });
                        }
                    </script>
                    <dl class="row">
                        <dt class="tit"> <label for="stock_count"><em>*</em>商品库存</label> </dt>
                        <dd class="opt">
                            <input type="text" name="stock_count" id="stock_count" style="width: 10%;" value="99999" maxlength="9" onpaste='this.value=this.value.replace(/^\D*([0-9]\d*)?.*$/, "$1");' onkeyup='this.value=this.value.replace(/^\D*([0-9]\d*)?.*$/, "$1");'>
                            <label> <input type="checkbox" name="stock_show" value="1" checked="checked"> 页面显示商品库存 </label>
                        </dd>
                    </dl>
                    <dl class="row">
                        <dt class="tit"> <label for="virtual_sales">虚拟销量</label> </dt>
                        <dd class="opt">
                            <input type="text" name="virtual_sales" id="virtual_sales" style="width: 10%;" value="0" maxlength="9" onpaste='this.value=this.value.replace(/^\D*([0-9]\d*)?.*$/, "$1");' onkeyup='this.value=this.value.replace(/^\D*([0-9]\d*)?.*$/, "$1");'>
                            <p class="notic">显示销量=实际销量+虚拟销量</p>
                        </dd>
                    </dl>
                </div>
                <dl class="row">
                    <dt class="tit"> <label for="goods_unit">商品单位</label> </dt>
                    <dd class="opt">
                        <label><input type="radio" name="goods_unit_radio" value="1" checked="true" onclick="selectGoodsUnit(1);">读取系统设置</label>
                        &nbsp;
                        <label><input type="radio" name="goods_unit_radio" value="2" onclick="selectGoodsUnit(2);">自定义</label>
                        <p class="notic">读取系统设置: [设置]-[商城设置]-[商品单位]</p>
                    </dd>
                </dl>
                <dl class="row" id="goods_unit_radio_2" style="display: none;">
                    <dt class="tit"> <label></label> </dt>
                    <dd class="opt">
                        <div class="inpit-word">
                            <input type="text" name="goods_unit" id="goods_unit" value="{$usersConfig.goods_unit}" placeholder="请输入商品单位" autocomplete="off" oninput="inputLengthShow(this, 'goods_unit');" maxlength="3" onpropertychange="if(value.length>3) value=value.substr(0,3)">
                            <div class="word"><span class="goods_unit_text_count">0</span>/<span class="num_count">3</span></div>
                        </div>
                    </dd>
                </dl>

                <div class="div_title"> 发货设置 </div>
                <dl class="row">
                    <dt class="tit"> <label>发货方式</label> </dt>
                    <dd class="opt">
                        <label> <input type="checkbox" class="logistics_type" name="logistics_type[]" value="1" checked='true'/>快递发货 </label>
                        {if condition="!empty($weappVerify['data']['openVerify'])"}
                        &nbsp;
                        <label> <input type="checkbox" class="logistics_type" name="logistics_type[]" value="2"/>到店核销 </label>
                        {/if}
                    </dd>
                </dl>

                <!-- <div class="div_title"> 物流设置 </div>
                <dl class="row">
                    <dt class="tit"> <label>运费设置</label> </dt>
                    <dd class="opt">
                        <label><input type="radio" name="freight_fee_set" value="1" checked="checked" onclick="freightFeeSet(1);">包邮</label>&nbsp;
                        <label><input type="radio" name="freight_fee_set" value="2" onclick="freightFeeSet(2);">选择模板</label>
                    </dd>
                </dl>
                <dl class="row" id="freightFeeSet" style="display: none;">
                    <dt class="tit"> <label>选择模板</label> </dt>
                    <dd class="opt">
                        <select name="freight_fee_tpl" id="freight_fee_tpl">
                            <option value="0">请选择</option>
                            {volist name="$freightTemplate" id="tpl"}
                            <option value="{$tpl.template_id}" {eq name="$tpl.default" value="1"} selected {/eq}>{$tpl.template_name}</option>
                            {/volist}
                        </select>
                        &nbsp; &nbsp;
                        <a href="JavaScript:void(0);" onclick="refreshFreightFeeTpl(0);">刷新</a>
                        &nbsp; &nbsp;
                        <a href="{:url('ShopFreight/index')}" target="_blank">添加模板</a>
                    </dd>
                </dl>
                <script type="text/javascript">
                    // 运费设置
                    function freightFeeSet(freight_fee_set) {
                        if (1 === parseInt(freight_fee_set)) {
                            $('#freightFeeSet').hide();
                        } else if (2 === parseInt(freight_fee_set)) {
                            $('#freightFeeSet').show();
                        }
                    }
                    // 刷新运费模板
                    function refreshFreightFeeTpl(freight_fee_tpl) {
                        layer_loading('正在处理');
                        $.ajax({
                            type: 'post',
                            url : "{:url('ShopProduct/ajaxGetTemplateList')}",
                            data: {freight_fee_tpl: freight_fee_tpl, _ajax: 1},
                            dataType: 'json',
                            success : function(res) {
                                layer.closeAll();
                                if (1 === parseInt(res.code)) {
                                    $('#freight_fee_tpl').empty().html(res.data);
                                } else {
                                    // 提示内容
                                    showErrorMsg(res.msg);
                                }
                            },
                            error: function(e) {
                                showErrorAlert(e.responseText);
                            }
                        });
                    }
                </script> -->

                <div class="div_title"> 商品状态 </div>
                <dl class="row">
                    <dt class="tit"> <label>上架设置</label> </dt>
                    <dd class="opt">
                        <label><input type="radio" name="arcrank" value="0" checked="checked">立即上架</label>&nbsp;
                        <label><input type="radio" name="arcrank" value="-1">放入仓库</label>
                    </dd>
                </dl>
                <div style="height: 30px;display: block;"></div>
            </div>
            <!-- 基础设置 -->

            <!-- 商品详情 -->
            <div class="ncap-form-default ey_ckeditor tab_div_2" style="display: none;">
                {include file="archives/get_field_addonextitem" /}
            </div>
            <!-- 商品详情 -->

            <!-- 商品参数 -->
            <div class="ncap-form-default tab_div_3" style="display: none;">
                <dl class="row">
                    <dd class="opt">
                        <a href="JavaScript:void(0);" id="addCustomParam" data-attr_id="{$maxAttrID}" onclick="addCustomParam(this);">+添加参数</a>
                        <div id="system_param" style="display: block;">
                            <dl class="row custom-row pb0">
                                <dt class="w60 text-l5">排序</dt>
                                <dt class="w140 text-l5"> 参数名称</dt>
                                <dt class="w350 text-l5"">参数值</dd>
                            </dl>
                            <div id='AttrSelectName' style="margin: 1px;"></div>
                            <div id='customParam' style="margin: 1px;"></div>
                        </div>
                    </dd>
                </dl>
                <script type="text/javascript">
                    // 默认添加自定义参数
                    $('#addCustomParam').click();

                    // 添加自定义参数
                    function addCustomParam(obj) {
                        var maxAttrID = $(obj).attr('data-attr_id');
                        // 规格值HTML
                        var html = [
                            '<dl class="row custom-box-row pt0">'+
                                '<dd class="w60"> <input type="text" size="4" name="sort_order['+maxAttrID+']" placeholder="100"> </dt>'+
                                '<dd class="w140"> <input type="text" size="10" name="attr_name['+maxAttrID+']" placeholder="输入参数名称" class="w120"> </dt>'+
                                '<dd class="w350">'+
                                    '<input type="text" size="40" name="attr_value['+maxAttrID+']" placeholder="输入参数值">'+
                                    '<a class="text_a" href="javascript:void(0);" onClick="delCustomParam(this);">&nbsp;&nbsp;删除</a>'+
                                '</dd>'+
                            '</dl>'
                        ];
                        // 加载一个规格值 input
                        $('#customParam').append(html);
                        // 自定义参数数量+1覆盖原值
                        $(obj).attr('data-attr_id', ++maxAttrID);
                    }

                    // 删除自定义参数
                    function delCustomParam(obj) {
                        $(obj).parent().parent().remove();
                    }

                    // 参数选择
                    function attrListSelect(obj) {
                        var aid = 0;
                        var list_id = $(obj).val();
                        if (parseInt(list_id) < 1) {
                            $("#AttrSelectName").empty();
                            return false;
                        }
                        // 商品栏目切换时 ajax 调用返回不同的属性输入框
                        $.ajax({
                            type:'GET',
                            data:{aid: aid, list_id: list_id, _ajax: 1},
                            url :"{:url('ShopProduct/ajax_get_shop_attr_input')}",
                            success:function(data) {
                                $("#AttrSelectName").empty().append(data);
                            }
                        });
                    }
                </script>
            </div>
            <!-- 商品参数 -->

            <!-- 更多设置 -->
            <div class="ncap-form-default tab_div_4" style="display:none;">
                <dl class="row">
                    <dt class="tit"> <label for="seo_title">SEO标题</label> </dt>
                    <dd class="opt">
                        <input type="text" name="seo_title" id="seo_title" class="input-txt">
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label for="seo_keywords">SEO关键词</label> </dt>
                    <dd class="opt">
                        <textarea rows="5" cols="60" id="seo_keywords" name="seo_keywords" style="height: 40px;"></textarea>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label for="seo_description">SEO描述</label> </dt>
                    <dd class="opt">
                        <textarea rows="5" cols="60" id="seo_description" name="seo_description" style="height: 60px;"></textarea>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit"> <label for="tempview">商品模板</label> </dt>
                    <dd class="opt">
                        <!-- <select name="tempview" id="tempview">
                            {volist name='$templateList' id='vo'}
                            <option value="{$vo}" {eq name='$vo' value='$tempview'}selected{/eq}>{$vo}</option>
                            {/volist}
                        </select> -->
                        <input type="hidden" name="tempview" value="{$tempview}" />
                        <input type="hidden" name="type_tempview" value="{$tempview}" />
                    </dd>
                </dl>
                <dl class="row {notin name='$seo_pseudo' value='2'}no-grey{/notin}">
                    <dt class="tit"> <label for="htmlfilename">自定义文件名</label> </dt>
                    <dd class="opt">
                        <input type="text" {notin name='$seo_pseudo' value='2'}readonly="readonly" title="仅在静态模式下使用"{/notin} value="" name="htmlfilename" id="htmlfilename" autocomplete="off" onkeyup="this.value=this.value.replace(/[^\w\-]/g,'-');" onpaste="this.value=this.value.replace(/[^\w\-]/g,'-');" class="input-txt {notin name='$seo_pseudo' value='2'}no-drop{/notin}">.html
                    </dd>
                </dl>
            </div>
            <!-- 更多设置 -->

            <div class="bot2" style="left: 150px;">
                <input type="hidden" name="prom_type" value="0">
                <input type="hidden" id="editor_addonFieldExt" value="">
                <a href="JavaScript:void(0);" onclick="check_submit();" class="ncap-btn-big ncap-btn-green w60">保存</a>
                <a class="ncap-btn-big ncap-btn-no w60 ml20" href="javascript:history.back();" title="返回">返回</a>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        // 选项卡切换列表
        $('.tab-base').find('.tab').click(function(){
            $('.tab-base').find('.tab').each(function(){
                $(this).removeClass('current');
            });
            $(this).addClass('current');
            var tab_index = $(this).data('index');
            $(".tab_div_1, .tab_div_2, .tab_div_3, .tab_div_4").hide();
            $(".tab_div_" + tab_index).show();
            layer.closeAll();
        });
    });

    $(document).ready(function() {
        inputLengthShow($('#goods_unit'), 'goods_unit');
    });

    function selectGoodsUnit(value) {
        $('#goods_unit_radio_2').hide();
        if (2 === parseInt(value)) {
            $('#goods_unit_radio_2').show().find('#goods_unit').focus();
        }
    }

    function inputLengthShow(obj, id) {
        var inputleg = $(obj).val().length;
        var maxlength = $(obj).attr('maxlength');
        if (parseInt(inputleg) > parseInt(maxlength)) {
            // showErrorMsg('字数请在' + maxlength + '字以内');
        } else {
            $('.' + id + '_text_count').text(inputleg);
        }
    }

    // 判断输入框是否为空
    function check_submit() {
        if ($.trim($('#title').val()) == '') {
            $($('.tab-base').find('.tab')[0]).trigger('click');
            $('#title').focus();
            showErrorMsg('请填写商品名称');
            return false;
        }
        else if ($.trim($('#litpic').val()) == '') {
            $($('.tab-base').find('.tab')[0]).trigger('click');
            showErrorMsg('请选择商品主图');
            return false;
        }
        else if ($.trim($('#users_price').val()) == '' || parseFloat($('#users_price').val()) === 0) {
            $($('.tab-base').find('.tab')[0]).trigger('click');
            $('#users_price').focus();
            showErrorMsg('请填写商品销售价');
            return false;
        }
        else if ($.trim($('#stock_count').val()) == '' || parseInt($('#stock_count').val()) === 0) {
            $($('.tab-base').find('.tab')[0]).trigger('click');
            $('#stock_count').focus();
            showErrorMsg('请填写商品库存量');
            return false;
        }

        // layer_loading('正在处理');
        layer.load(2, {
            shade: [0.1,'#fff'] //0.1透明度的白色背景
        });
        setTimeout(function () {
            editor_auto_210607();
            $('#post_form').submit();
        }, 1);
    }

    // 上传产品相册回调函数
    function proimg_call_back(paths, isSync) {
        if (true == isSync && $('#litpicSync').length > 0) {
            loadImageInfo($('#litpicSync'), paths[0]);
        } else {
            var last_div = $(".images_upload_tpl").html();
            if (true == isSync) {
                last_div = last_div.replace('class="images_upload images_upload_html"', 'class="images_upload images_upload_html" id="litpicSync"');
            }
            for (var i = 0; i < paths.length; i++) {
                if (true == isSync) {
                    $(".sort-list-img .images_upload").eq(0).before(last_div);
                    loadImageInfo($(".sort-list-img .images_upload").eq(0), paths[i]);
                } else {
                    if ($(".sort-list-img .images_upload_html").length > 0) {
                        $(".sort-list-img .images_upload_html:last").after(last_div);
                    } else {
                        $(".sort-list-img .images_upload:last").before(last_div);
                    }
                    loadImageInfo($(".sort-list-img .images_upload_html:last"), paths[i]);
                }
            }
        }
    }

    function loadImageInfo(obj, image) {
        obj.find('input').val(image);
        obj.find('img').attr('src', image);
        obj.find('a:eq(1)').attr('onclick', "ClearPicArr2(this,'"+image+"');").text('');
        obj.find('a:eq(0)').attr('href', 'javascript:void(0);').attr('onclick','Images("'+image+'", 900, 600);');
    }

    // 上传之后删除组图input
    function ClearPicArr2(obj,path) {
        $(obj).parent().parent().remove();
        $.ajax({
            type:'POST',
            url:"{:url('Uploadimgnew/delupload')}",
            data:{action:"del", filename:path,_ajax:1},
            success: function(){}
        });
    }

    /** 以下产品相册的拖动排序相关 js*/
    $( ".sort-list-img" ).sortable({
        start: function( event, ui) {

        },
        stop: function( event, ui ) {

        }
    });
    // 因为他们要拖动，所以尽量设置他们的文字不能选择
    $(".sort-list-img").disableSelection();
    
    
    // 本地上传
    function videoUpload(obj) {
        // 获取文件路径名
        var file = $(obj)[0].files[0];
    
        // 验证上传格式
        var fileName = file.name;
        var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
        var ext = judgeExt(fileExt);
        if (ext == -1) {
            showErrorMsg('不支持选中的视频格式，可在附件设置中修改');
            return false;
        }
    
        // 验证上传大小
        var size = "{$upload_max_filesize}";
        if (file.size > size) {
            showErrorMsg('视频大小超过限制，可在附件设置中修改');
            return false;
        }
    
        // 定义上传数据
        var formData = new FormData();
        formData.append('file', file);
    
        // 执行上传
        layer_loading('上传本地');
        $.ajax({
            type: 'post',
            url : "{:url('Ueditor/upVideo', ['savepath'=>'media'])}",
            data: formData,
            contentType: false,
            processData: false,
            dataType: 'json',
            xhr: function () {
                myXhr = $.ajaxSettings.xhr();
                if (myXhr.upload) {
                    myXhr.upload.addEventListener('progress', function(e) {
                        var curr = e.loaded;
                        var total = e.total;
                        process = parseInt(curr / total * 100);
                        $("#videoUpload").html('上传中...'+process+"%");
                    });
                }
                return myXhr;
            },
            success: function (res) {
                layer.closeAll();
                $("#videoUpload").html('上传成功');
                setTimeout(function() {
                    $('#videoUpload').html('本地上传');
                }, 2000);
                if ("SUCCESS" == res.state) {
                    $('#video').attr('src', res.url);
                    $('#video_times').val(res.time);
                    $("#video_paths").val(res.url);
                } else {
                    showErrorMsg(res.msg);
                }
            }
        });
    }
    
    // 手动更新视频路径
    function videoPaths(obj) {
        $('#video').attr('src', $(obj).val());
    }
    
    // 视频清除
    function videoClear() {
        $('#video_paths').val('');
        $('#video_times').val();
        $('#video').attr('src', '');
    }
    
    // 验证格式
    function judgeExt(ext) {
        var type = "{$media_type}";
        var extArr = [];
        extArr = type.split("|");
        var ext = ext.replace(".", "");
        return extArr.indexOf(ext);
    }
</script>

<script type="text/javascript">
    try{
        var mt20_1649209614 = sessionStorage.getItem("mt20_1649209614");
        if (mt20_1649209614 == 1) {
            $("#geduan_div").removeClass("h10");
        } else {
            $("#geduan_div").addClass("h10");
        }
    }catch(e){}
</script>
{include file="public/footer" /}
